#ifndef ERRORCORRECTION_H
#define ERRORCORRECTION_H

#include <map>
#include <vector>

#include "symbol.h"

namespace qrcode{

class ErrorCorrection
{
private:
    std::map<int, int> alpha;
    std::map<int, block_int> generatorPolynomials;

    void XOR285(int &x);
    int ToInt(codeword &c);
    std::vector<char> ToBinaryV(int &x);
    block_int ToblockInt(block &b);
    block ToBlock(block_int &b);
    //void Block_intToBase2exponent(block_int &b);
    void IntToBase2exponent(int &x);
    void Base2exponentToBlock_int(block_int &b);
    void Base2exponentToInt(int &x);

    void MultiplyLeadTerm(block_int &b, int x);
    void PolyXOR(block_int &b, block_int &b1);

public:
    ErrorCorrection();
    block_int GetGeneratorPolynomials(int ECCodewordsPerBlock);
    group Ecoding(group &codeGroup, block_int &poly);
    block GeneratingECC(block_int msgPoly, block_int genPoly);
    bool IsCorrect(std::vector<std::vector<int>> _block, std::vector<std::vector<int>> _ecb);
};

}

#endif // ERRORCORRECTION_H
